<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<style type="text/css">
    .font_style {
        color: blue;
        font-size: 11pt;
        font-weight: bold;
    }
</style>

<script type="text/javascript" language="JavaScript">
    $(document).ready(function () {
        $("#add-hotel-mapping").validate();
    });
    function list_hotel() {
        $("#list_hotel_form").attr("action", "list.dhtml");
        $("#list_hotel_form").submit();
    }
    function add_hotel(obj) {
        obj.preventDefault();
        window.location.href = "./view.dhtml";
    }
    function query_hotel(obj) {
        var hotelMappingId = obj.parent().parent().children("input:hidden").eq(0).val();
        var hotelMappingIdNode = "<input type=\"hidden\" name=\"hotel.propertyID\" value=\"" + propertyID + "\"/>";
        $("#list_hotel_form").append(hotelMappingIdNode);
        $("#list_hotel_form").attr("action", "view.dhtml?hotel.propertyID=");
        $("#list_hotel_form").submit();
    }
    function show_add_div(obj) {
        obj.preventDefault();
        window.location.href = "list.dhtml";
    }
    function show_hotel_list_div() {
        $("#add_hotel_div").hide();
        $("#hotel_list").show();
    }
    $(function () {
        $("#edit_hotel_form").validate();
    })
    function refreshCache(triggerObj) {
        var spanObj = triggerObj.parent().find("span:eq(0)");
        spanObj.empty();
        spanObj.append('processing ...');
        $.ajax({
            type:"GET",
            url:"refreshCache.dhtml",
            dataType:"json",
            success:function (echo) {
                spanObj.empty();
                if (!echo.result) {
                    spanObj.attr("style", "color:red");
                }
                spanObj.append(echo.message);
            }
        });
    }
</script>
<h1>Hotel</h1>

<div class="main">
    <div align="right">
        <span class="font_style"></span>
        <input type="button" value="RefreshCache" onclick="refreshCache($(this));" class="common_button">
    </div>

    <div class="box_side search_hotel clearfix">
        <form id="list_hotel_form" method="GET">
            <ul>
                <li><label>LCB Hotel Code：</label>
                    <s:textfield name="hotelCondition.propertyID" cssClass="text"/>
                </li>
                <li><label>Derby Hotel Code：</label>
                    <s:textfield id="passport" name="hotelCondition.passport" size="45" cssClass="text"/>
                </li>
                <li><label>LCB Hotel Name：</label>
                    <s:textfield name="hotelCondition.name" cssClass="text"/>
                </li>
                <li><label>Status：</label>
                    <s:select name="hotelCondition.status" cssClass="select" value="hotelCondition.status" headerKey=""
                              headerValue=""
                              list="@com.derbysoft.lowcostadapter.commons.model.Status@values()"/>
                </li>
            </ul>
            <input type="button" value="Search" onclick="list_hotel();" class="common_button">
        </form>
    </div>
</div>
<div class="main" id="hotel_list">
    <jsp:include page="../../common/pagination.jsp"/>
    <div align="right">
        <input class="common_button" type="button" value="Add"
               onclick="window.location.href='./view.dhtml'">
        <input class="common_button" type="button" value="Import"
               onclick="window.location.href='./importView.dhtml'">
    </div>
    <table id="channel" class="table_list" cellpadding="0" cellspacing="0">
        <thead>
        <tr>
            <th>LCB Hotel Code</th>
            <th>Derby Hotel Code</th>
            <th>LCB Hotel Name</th>
            <th>Status</th>
            <th>Operate</th>
        </tr>
        </thead>
        <tbody>
        <s:iterator value="paginater.objects">
            <tr>
                <td>${propertyID}</td>
                <td>${passport}</td>
                <td>${name}</td>
                <td>${status}</td>
                <td><a href="edit.dhtml?hotel.propertyID=${propertyID}">Edit</a></td>
            </tr>
        </s:iterator>
        </tbody>
    </table>
    <jsp:include page="../../common/pagination.jsp"/>
</div>
<form id="edit_hotel_form" method="post">
    <s:if test="newHotelMapping!=null">
        <div class="main">
            <jsp:include page="../../common/messages.jsp"/>
            <h1>Edit Hotel Mapping</h1>
            <ul>
                <li style="margin-left:50px;">
                    <label>LCB Hotel Code：</label>
                    <input type="hidden" name="hotel.propertyID" value="${newHotelMapping.propertyID}">
                    <input name="hotel.propertyID" value="${newHotelMapping.propertyID}" readonly="true">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <label>Derby Hotel Code：</label>
                    <input name="hotel.passport" class="required" maxlength="50"
                           value="${newHotelMapping.passport}" size="50">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <label>LCB Hotel Name：</label>
                    <input name="hotel.name" value="${newHotelMapping.name}">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <label>Status：</label>
                    <s:select name="hotel.status" cssClass="select" value="newHotelMapping.status"
                              list="@com.derbysoft.lowcostadapter.commons.model.Status@values()"/>
                    <input value="Update" class="common_button" type="button" onclick="edit_hotel();">
                    <input value="Back" class="common_button" type="button" onclick="list_hotel();">
                </li>
            </ul>
        </div>
    </s:if>
</form>



